package com.example.sqlite;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class AddActivity extends AppCompatActivity {

    private EditText name;
    private EditText clas;
    private EditText number;
    public DBOpenHelper db;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);
        name = findViewById(R.id.add_name);
        clas = findViewById(R.id.add_class);
        number = findViewById(R.id.add_number);
        db = new DBOpenHelper(this, 1);

        Button btn = findViewById(R.id.add_btn);
        btn.setOnClickListener(v -> {
            Student student = new Student();
            student.setName(name.getText().toString());
            student.setClas(clas.getText().toString());
            student.setNumber(number.getText().toString());
            db.insert(student);
            finish();
        });
    }
}